﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.Versions.Common.Entities;
using PSE.Framework.Versions.Common.Gateway;

namespace PSE.Framework.Versions.Engine
{
    public class NetworkDiscovery : IDiscoveryVersions
    {
        private string _servicePath = string.Empty;

        public NetworkDiscovery(string servicePath)
        {
            if (string.IsNullOrEmpty(servicePath))
                throw new ArgumentNullException("servicePath");

            _servicePath = servicePath;
        }

        public Product Get(string productName, int majorVersion, string serverName)
        {
            if (string.IsNullOrEmpty(productName))
                throw new ArgumentNullException("productName");

            Product product = null;

            Proxy<IDiscoveryVersions>.Instance.Connect(_servicePath, (client) =>
            {
                product = client.Get(productName, majorVersion, serverName);
            });
            return product;
        }
    }
}